<?php

require_once dirname(__FILE__) . '/../../Extension/Params.php';
require_once dirname(__FILE__) . '/TextValues.php';

class Rams_Extension_FilterParams extends Raws_Extension_Params
{
  
  // protected $_rootNamespace = 'raws';
  // protected $_rootElement = 'params';

    # child elements of the params element
    protected $_name = null;
    protected $_threshold = null;
    protected $_filter = null;
    protected $_operator = null;
    protected $_last_threshold_warning = null;
    protected $_email = null;

    public function __construct($name = null, $threshold = null, $filter = null, $operator = null, $last_threshold_warning = null, $email = null) 
    {
        parent::__construct();
        $this->setName($name);
        $this->setThreshold($threshold);
        $this->setFilter($filter);
        $this->setOperator($operator);
        $this->setLastThresholdWarning($last_threshold_warning);
        $this->setEmail($email);
    }
    
    /**
     * Retrieves a DOMElement which corresponds to this element and all
     * child properties.  This is used to build an entry back into a DOM
     * and eventually XML text for application storage/persistence.
     *
     * @param DOMDocument $doc The DOMDocument used to construct DOMElements
     * @return DOMElement The DOMElement representing this element and all
     *          child properties.
     */
    public function getDOM($doc = null)
    {
        $element = parent::getDOM($doc);
        if ($this->_name !== null) {
            $element->appendChild($this->_name->getDOM($element->ownerDocument));
        }
        if ($this->_threshold !== null) {
            $element->appendChild($this->_threshold->getDOM($element->ownerDocument));
        }
        if ($this->_filter !== null) {
            $element->appendChild($this->_filter->getDOM($element->ownerDocument));
        }
        if ($this->_operator !== null) {
            $element->appendChild($this->_operator->getDOM($element->ownerDocument));
        }
        if ($this->_last_threshold_warning !== null) {
            $element->appendChild($this->_last_threshold_warning->getDOM($element->ownerDocument));
        }
        if ($this->_email !== null) {
            $element->appendChild($this->_email->getDOM($element->ownerDocument));
        }
        return $element;
    }

    /**
     * Creates individual Entry objects of the appropriate type and
     * stores them as members of this entry based upon DOM data.
     *
     * @param DOMNode $child The DOMNode to process
     */
    protected function takeChildFromDOM($child)
    {
        $absoluteNodeName = $child->namespaceURI . ':' . $child->localName;
        
        switch ($absoluteNodeName) {
            case $this->lookupNamespace('raws') . ':' . 'name'; 
                $name = new Rams_Extension_Name();
                $name->transferFromDOM($child);
                $this->_name = $name;
                break;
            case $this->lookupNamespace('raws') . ':' . 'threshold'; 
                $threshold = new Rams_Extension_Threshold();
                $threshold->transferFromDOM($child);
                $this->_threshold = $threshold;
                break;
            case $this->lookupNamespace('raws') . ':' . 'filter'; 
                $filter = new Rams_Extension_Filter();
                $filter->transferFromDOM($child);
                $this->_filter = $filter;
                break;
            case $this->lookupNamespace('raws') . ':' . 'operator'; 
                $operator = new Rams_Extension_Operator();
                $operator->transferFromDOM($child);
                $this->_operator = $operator;
                break;
            case $this->lookupNamespace('raws') . ':' . 'last_threshold_warning'; 
                $last_threshold_warning = new Rams_Extension_LastThresholdWarning();
                $last_threshold_warning->transferFromDOM($child);
                $this->_last_threshold_warning = $last_threshold_warning;
                break;
            case $this->lookupNamespace('raws') . ':' . 'email'; 
                $email = new Rams_Extension_Email();
                $email->transferFromDOM($child);
                $this->_email = $email;
                break;
            default:
                parent::takeChildFromDOM($child);
                break;
        }
    }
    
    public function getName()
    {
        return $this->_name;
    }

    public function setName($value)
    {
        $this->_name = $value;
        return $this;
    }

    public function getThreshold()
    {
        return $this->_threshold;
    }

    public function setThreshold($value)
    {
        $this->_threshold = $value;
        return $this;
    }

    public function getFilter()
    {
        return $this->_filter;
    }

    public function setFilter($value)
    {
        $this->_filter = $value;
        return $this;
    }

    public function getOperator()
    {
        return $this->_operator;
    }

    public function setOperator($value)
    {
        $this->_operator = $value;
        return $this;
    }


    public function getLastThresholdWarning()
    {
        return $this->_last_threshold_warning;
    }

    public function setLastThresholdWarning($value)
    {
        $this->_last_threshold_warning = $value;
        return $this;
    }
    
    public function getEmail()
    {
        return $this->_email;
    }

    public function setEmail($value)
    {
        $this->_email = $value;
        return $this;
    }
    

}
